package com.yeren.thread.changeState.yield;

public class TestYield {
	public static void main(String[] args) {
		Thread t1 = new MyThreadYield();
		Thread t2 = new Thread(new MyRunnable());

		t2.start();
		t1.start();
	}
}

class MyThreadYield extends Thread {
	public void run() {
		for (int i = 0; i < 10; i++) {
			System.out.println("线程A第" + i + "次执行！");
		}
	}
}

class MyRunnable implements Runnable {
	public void run() {
		for (int i = 0; i < 10; i++) {
			System.out.println("线程B第" + i + "次执行！");
			Thread.yield();
		}
	}
}